package com.niiwoo.civet.account.dto.response;

import com.niiwoo.tripod.lanmao.enums.UserRoleEnum;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * Created by lujing on 2017/11/27.
 */
@Getter
@Setter
public class AccountAmountDTO implements Comparable<AccountAmountDTO>,Serializable{
    private static final long serialVersionUID = -7867997531155036864L;
    private Long accountId;

    private Byte accountRole;

    private String accountNo;

    private BigDecimal availableAmount;

    private Byte activeAccount;

    private Byte order;



    public void setAccountRole(Byte accountRole){
        this.accountRole = accountRole;
        UserRoleEnum userRoleEnum = UserRoleEnum.enumOf(accountRole);
        switch (userRoleEnum) {
            case INVESTOR:
                if(Byte.valueOf("0").equals(this.activeAccount)) {
                    this.order = Byte.valueOf("10");
                } else {
                    this.order = Byte.valueOf("1");
                }
                break;
            case BORROWERS:
                if(Byte.valueOf("0").equals(this.activeAccount)) {
                    this.order = Byte.valueOf("20");
                } else {
                    this.order = Byte.valueOf("2");
                }
                break;
            case GUARANTEECORP:
                if(Byte.valueOf("0").equals(this.activeAccount)) {
                    this.order = Byte.valueOf("30");
                } else {
                    this.order = Byte.valueOf("3");
                }
                break;
            default:
                this.order = Byte.valueOf("99");
                break;
        }

    }

    @Override
    public int compareTo(AccountAmountDTO o) {
        return this.order - o.getOrder();//如果都激活了，就按照角色排序
    }
}
